import React,{useState} from 'react'
import UserModel from '../model/userModel'
interface IProps{
    addListItem:(item:UserModel)=>void
}

export default function UserAdd({addListItem}:IProps) {
    const [info, setinfo] = useState<UserModel>({
        username:"",
        userage:""
    })
  return (
    <div>
        <div>用户名 <input value = {info.username} onChange={(e)=>{
            setinfo({...info,username:e.target.value})
            
        }}/> </div>
        <div>年龄 <input value = {info.userage} onChange={(e)=>{
            setinfo({...info,userage:e.target.value})
            
        }}/> </div>
        <button onClick={()=>{
            addListItem(info);
        }}>新增</button>
    </div>
  )
}
